package forme.grapping.app;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.app.AlertDialog;
import android.content.DialogInterface;

public class FormeGrappingActivity extends Activity {
	
	private Button circle,triangle,square;
	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        circle = (Button) findViewById(R.id.circlebutton);
        triangle = (Button) findViewById(R.id.trianglebutton);
        square = (Button) findViewById(R.id.squarebutton);
        
    /** Set of clickListener on the different buttons **/
        circle.setOnClickListener(new ClickListener_Button());
        triangle.setOnClickListener(new ClickListener_Button());
        square.setOnClickListener(new ClickListener_Button());
        
    }
    
    
    /** Class defining what happened when the user clicks on a button_form **/
    
    class ClickListener_Button implements Button.OnClickListener
    {
       	
    @Override
        public void onClick(View button) {
    	
    	AlertDialog.Builder messageBox = new AlertDialog.Builder(FormeGrappingActivity.this);	
    	String chosen_form = new String();
    	
    	/** Check which button was selected and return the string of the form selected **/
    	
    	switch(button.getId()){
		case R.id.circlebutton:
			chosen_form= "Circle";
			break;
		
		case R.id.trianglebutton:
			chosen_form= "Triangle";
			break;
		
		case R.id.squarebutton:
			chosen_form= "Square";
			break;
    	}  
    	
    	/** Display of an alert box asking for confirmation of the chosen form 
    	 	If it's yes so the NEXT STEP is for the arm to point at the right form
    	 	It it's no the user chose an another form**/
    	
    	messageBox.setMessage("Do you want to look for the " + chosen_form + " Form?");
		messageBox.setPositiveButton("Yes", 
				new DialogInterface.OnClickListener() {
			
				@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						Toast.makeText(FormeGrappingActivity.this,"Now if the form exit the arm will point at it",Toast.LENGTH_SHORT).show();
					}
				});
		messageBox.setNegativeButton("No", 
				new DialogInterface.OnClickListener() {
			
				@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						Toast.makeText(FormeGrappingActivity.this,"Please chose another form",Toast.LENGTH_SHORT).show();
					}
				});
		messageBox.show();
    	}
    }
    
    
}